package com.jic.veteran.controller;

import com.jic.veteran.common.api.CommonResult;
import com.jic.veteran.model.UmsMember;
import com.jic.veteran.service.UmsMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会员等级管理Controller
 * Created by macro on 2018/4/26.
 */
@Controller
@Api(tags = "UmsMemberController")
@RequestMapping("/umsmember")
public class UmsMemberController {
    @Autowired
    private UmsMemberService umsMemberService;

    @ApiOperation("查询会员列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<UmsMember>> list(@RequestParam(value = "cname",required = false) String cname,
                                              @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<UmsMember> umsMemberList = umsMemberService.list(cname,pageSize,pageNum);
        return CommonResult.success(umsMemberList);
    }

    @ApiOperation("查询会员详细信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<UmsMember> getUmsMember(@PathVariable("id") Long id) {
        UmsMember umsMember = umsMemberService.getItem(id);
        return CommonResult.success(umsMember);
    }
}
